package cn.iocoder.yudao.module.wine.dal.mysql.memberopenlog;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.wine.dal.dataobject.memberopenlog.MemberOpenLogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.memberopenlog.vo.*;

/**
 * 会员开通记录 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface MemberOpenLogMapper extends BaseMapperX<MemberOpenLogDO> {

    default PageResult<MemberOpenLogRespVO> selectPage(MemberOpenLogPageReqVO reqVO) {
        return selectJoinPage(reqVO, MemberOpenLogRespVO.class,new MPJLambdaWrapperX<MemberOpenLogDO>()
                .eqIfPresent(MemberOpenLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberOpenLogDO::getPrice, reqVO.getPrice())
                .eqIfPresent(MemberOpenLogDO::getTradeNo, reqVO.getTradeNo())
                .eqIfPresent(MemberOpenLogDO::getMemberTypeId, reqVO.getMemberTypeId())
                .eqIfPresent(MemberOpenLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(MemberOpenLogDO::getCreateTime, reqVO.getCreateTime())
                .leftJoin(MemberUserDO.class,MemberUserDO::getId,MemberOpenLogDO::getUserId)
                .selectAll(MemberOpenLogDO.class)
                .selectAs(MemberUserDO::getNickname,MemberOpenLogRespVO::getNickname)
                .selectAs(MemberUserDO::getName,MemberOpenLogRespVO::getName)
                .orderByDesc(MemberOpenLogDO::getId));
    }

}
